package Project;
//______________________________________________________________________________

public class Reporte extends javax.swing.JDialog {
//_____________________________ATRIBUTOS________________________________________

    private IniciarReporte jasper;
    int opcion;
//_____________________________CONSTRUCTOR______________________________________

    public Reporte(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jasper = new IniciarReporte();
        this.setLocationRelativeTo(rootPane);
    }
//______________________________________________________________________________

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dlgCargandoDatos = new javax.swing.JDialog();
        pbCargarDatos = new javax.swing.JProgressBar();
        jPanel2 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        cbxEntidad = new javax.swing.JComboBox();
        btnGenerarReporte = new javax.swing.JButton();

        dlgCargandoDatos.setTitle("Generando Reporte...");
        dlgCargandoDatos.setMinimumSize(new java.awt.Dimension(267, 72));
        dlgCargandoDatos.setModal(true);
        dlgCargandoDatos.setResizable(false);

        pbCargarDatos.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout dlgCargandoDatosLayout = new javax.swing.GroupLayout(dlgCargandoDatos.getContentPane());
        dlgCargandoDatos.getContentPane().setLayout(dlgCargandoDatosLayout);
        dlgCargandoDatosLayout.setHorizontalGroup(
            dlgCargandoDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgCargandoDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbCargarDatos, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE)
                .addContainerGap())
        );
        dlgCargandoDatosLayout.setVerticalGroup(
            dlgCargandoDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgCargandoDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbCargarDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Generar Reporte en PDF, XLS, DOC");
        setMaximumSize(new java.awt.Dimension(427, 154));
        setMinimumSize(new java.awt.Dimension(427, 154));
        setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Generar Reporte", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 12), new java.awt.Color(0, 0, 0))); // NOI18N

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel4.setText("Seleccione entidad a realizar reporte:");

        cbxEntidad.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        cbxEntidad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Accidentes", "Conductores", "Dueño de los vehiculos", "Rutas", "Vehiculos" }));
        cbxEntidad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        btnGenerarReporte.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnGenerarReporte.setText("Generar Reporte");
        btnGenerarReporte.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        btnGenerarReporte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGenerarReporteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addGap(10, 10, 10)
                .addComponent(cbxEntidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnGenerarReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbxEntidad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                .addComponent(btnGenerarReporte, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
//______________________________________________________________________________

private void btnGenerarReporteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerarReporteActionPerformed

    opcion = cbxEntidad.getSelectedIndex();

    switch (opcion) {
        case 0:
            jasper.ejecutarReporte("ma", "Accidentes", "AccidentesPDF");
            break;
        case 1:
            // this.dispose();
            jasper.ejecutarReporte("ma", "Conductores", "Conductores");
            break;
        case 2:
            //this.dispose();
            jasper.ejecutarReporte("ma", "Dueño", "DuenoVehiculo");
            break;
        case 3:
            //  this.dispose();
            jasper.ejecutarReporte("ma", "Rutas", "Rutas");
            break;
        case 4:
            jasper.ejecutarReporte("ma", "Vehiculos", "Vehiculos");
            break;
    }

}//GEN-LAST:event_btnGenerarReporteActionPerformed
//______________________________________________________________________________
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnGenerarReporte;
    private javax.swing.JComboBox cbxEntidad;
    private javax.swing.JDialog dlgCargandoDatos;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JProgressBar pbCargarDatos;
    // End of variables declaration//GEN-END:variables
}
